/*     */ package com.infoservice.schedule.po;
/*     */ 
/*     */ import com.infoservice.po3.POFactory;
/*     */ import com.infoservice.po3.POFactoryBuilder;
/*     */ import com.infoservice.po3.bean.PageResult;
/*     */ import com.infoservice.po3.callbackimpl.POCallBack;
/*     */ import com.infoservice.po3.core.context.POContext;
/*     */ import com.infoservice.po3.core.exceptions.DAOException;
/*     */ import com.infoservice.schedule.Constant;
/*     */ import com.infoservice.schedule.ScheduleException;
/*     */ import com.infoservice.schedule.generator.TaskPlanInfo;
/*     */ import com.infoservice.schedule.po.pos.TaskInfoPO;
/*     */ import com.infoservice.schedule.po.pos.TaskPO;
/*     */ import com.infoservice.schedule.queue.TaskBean;
/*     */ import java.util.LinkedList;
/*     */ import java.util.List;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class ScheduleDao
/*     */ {
/*  40 */   private static Logger logger = Logger.getLogger(ScheduleDao.class.getSimpleName());
/*     */ 
/*     */   public static List<TaskInfoPO> loadTaskInfoPO(int count)
/*     */     throws ScheduleException
/*     */   {
/*  50 */     POFactory factory = POFactoryBuilder.getInstance();
/*  51 */     String sql = "select TI.TASK_ID,TI.TASK_DURATION,TI.TASK_MANUAL,TI.TASK_PRIORITY,TI.TASK_TYPE,TI.ACTION_DESC,TI.ACTION_ID,TI.ACTION_NAME,TI.P1NAME,TI.P2NAME,TI.P3NAME,TI.P4NAME,TI.P5NAME FROM TASK_INFO TI WHERE TI.TASK_STATUS = ? AND TI.TASK_MANUAL = ? ORDER BY TI.TASK_PRIORITY DESC";
/*     */ 
/*  53 */     List params = new LinkedList();
/*  54 */     params.add(Integer.valueOf(1));
/*  55 */     params.add("SYSTEM");
/*  56 */     return factory.pageQuery(sql, params, new POCallBack(factory, TaskInfoPO.class), count, 1).getRecords();
/*     */   }
/*     */ 
/*     */   public static LinkedList<TaskBean> loadPendQueue()
/*     */   {
/*     */     try
/*     */     {
/*  64 */       POFactory factory = POFactoryBuilder.getInstance();
/*  65 */       String sql = "SELECT TP.P1VALUE,TP.P2VALUE,TP.P3VALUE,TP.P4VALUE,TP.P5VALUE,TP.PLAN_END,TP.PLAN_START,TP.PLAN_ID,TP.PLAN_IGNORE_FLAG,TP.PLAN_PATTERN,TP.PLAN_PRIORITY,TP.PLAN_REPEAT_TYPE,TP.PLAN_RUN_TYPE,TP.PLAN_START_TIMEOUT,TP.PLAN_STATUS,TP.TASK_INTERVAL,TP.PLAN_EXECUTE_TIMES,TP.PLAN_LAST_EXECUTE_TIME,TI.ACTION_DESC,TI.ACTION_ID,TI.ACTION_NAME,TI.P1NAME,TI.P2NAME,TI.P3NAME,TI.P4NAME,TI.P5NAME,TI.TASK_DURATION,TI.TASK_MANUAL,TI.TASK_PRIORITY,TI.TASK_STATUS,TI.TASK_TYPE,TI.TASK_ID ,T.LOG_ID,T.PLAN_START_TIME FROM TASK_INFO TI,TASK_PLAN TP,TASK T WHERE T.TASK_ID = TI.TASK_ID AND T.PLAN_ID = TP.PLAN_ID AND TP.TASK_ID = TI.TASK_ID AND  TP.PLAN_STATUS = ? AND TI.TASK_STATUS = ? AND T.MARKER = ? ORDER BY TP.PLAN_PRIORITY DESC,TI.TASK_PRIORITY DESC,T.PLAN_START_TIME ASC";
/*     */ 
/*  74 */       logger.debug("sql===>" + sql);
/*  75 */       List params = new LinkedList();
/*  76 */       params.add(Integer.valueOf(1));
/*  77 */       params.add(Integer.valueOf(1));
/*  78 */       params.add(Integer.valueOf(0));
/*  79 */       PageResult result = factory.pageQuery(sql, params, new TaskBeanCallBack(), Constant.TASK_LOAD_COUNT, 1);
/*  80 */       logger.debug("getCurPage====" + result.getCurPage());
/*  81 */       logger.debug("getPageSize====" + result.getPageSize());
/*  82 */       LinkedList list = (LinkedList)result.getRecords();
/*  83 */       POContext.endTxn(true);
/*  84 */       LinkedList localLinkedList1 = list;
/*     */       return localLinkedList1;
/*     */     } catch (DAOException e) {
/*  86 */       logger.error(e.getMessage(), e);
/*  87 */       POContext.endTxn(false);
/*  88 */       throw new ScheduleException(null, null, e);
/*     */     } finally {
/*  90 */       POContext.cleanTxn();
/*  91 */     }throw localObject;
/*     */   }
/*     */ 
/*     */   public static List<TaskPlanInfo> loadTaskPlanInfo(int count)
/*     */   {
/*  99 */     POFactory factory = POFactoryBuilder.getInstance();
/* 100 */     String sql = "select TP.*,TI.TASK_MANUAL,TI.P1NAME,TI.P2NAME,TI.P3NAME,TI.P4NAME,TI.P5NAME from TASK_PLAN TP,TASK_INFO TI WHERE TI.TASK_STATUS = ? AND TI.TASK_MANUAL = ? AND TP.TASK_ID = TI.TASK_ID AND TP.PLAN_STATUS = ? ORDER BY TP.PLAN_PRIORITY DESC,TI.TASK_STATUS DESC";
/*     */ 
/* 102 */     List params = new LinkedList();
/* 103 */     params.add(Integer.valueOf(1));
/* 104 */     params.add("SYSTEM");
/* 105 */     params.add(Integer.valueOf(1));
/* 106 */     return factory.pageQuery(sql, params, new TaskPlanInfoCallBack(), count, 1).getRecords();
/*     */   }
/*     */ 
/*     */   public static List<TaskPlanInfo> loadAllTaskPlanInfo()
/*     */   {
/* 113 */     POFactory factory = POFactoryBuilder.getInstance();
/* 114 */     String sql = "select TP.*,TI.TASK_MANUAL,TI.P1NAME,TI.P2NAME,TI.P3NAME,TI.P4NAME,TI.P5NAME from TASK_PLAN TP,TASK_INFO TI WHERE TI.TASK_STATUS = ? AND TI.TASK_MANUAL = ? AND TP.TASK_ID = TI.TASK_ID AND TP.PLAN_STATUS = ? ORDER BY TP.PLAN_PRIORITY DESC,TI.TASK_STATUS DESC";
/*     */ 
/* 116 */     List params = new LinkedList();
/* 117 */     params.add(Integer.valueOf(1));
/* 118 */     params.add("SYSTEM");
/* 119 */     params.add(Integer.valueOf(1));
/* 120 */     return factory.select(sql, params, new TaskPlanInfoCallBack());
/*     */   }
/*     */ 
/*     */   public static TaskPO loadTaskPoByTiTpID(long taskId, long planId)
/*     */   {
/* 129 */     POFactory factory = POFactoryBuilder.getInstance();
/* 130 */     String sql = "select * from TASK WHERE TASK_ID = ? AND PLAN_ID = ? ORDER BY PLAN_START_TIME DESC";
/* 131 */     List params = new LinkedList();
/* 132 */     params.add(Long.valueOf(taskId));
/* 133 */     params.add(Long.valueOf(planId));
/* 134 */     List list = factory.pageQuery(sql, params, new POCallBack(factory, TaskPO.class), 1, 1).getRecords();
/* 135 */     if ((list != null) && (list.size() > 0)) {
/* 136 */       return (TaskPO)list.get(0);
/*     */     }
/* 138 */     return null;
/*     */   }
/*     */ }

/* Location:           D:\Workspace\Work\ASMP_DE\lib\frame3\InfoSchedule_1.0.03.jar
 * Qualified Name:     com.infoservice.schedule.po.ScheduleDao
 * JD-Core Version:    0.6.0
 */